<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">


  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="linux,命令," />










<meta name="description" content="网络 apt install net-tools       # ifconfigapt install iputils-ping     # pingnetstat -ant | grep 4000     #查看端口占用">
<meta name="keywords" content="linux,命令">
<meta property="og:type" content="article">
<meta property="og:title" content="linux常用命令">
<meta property="og:url" content="http://tomasyao.gitee.info/2017/07/11/linux常用命令/index.html">
<meta property="og:site_name" content="Tomasyao">
<meta property="og:description" content="网络 apt install net-tools       # ifconfigapt install iputils-ping     # pingnetstat -ant | grep 4000     #查看端口占用">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-11-30T04:02:41.048Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="linux常用命令">
<meta name="twitter:description" content="网络 apt install net-tools       # ifconfigapt install iputils-ping     # pingnetstat -ant | grep 4000     #查看端口占用">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"hide","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://tomasyao.gitee.info/2017/07/11/linux常用命令/"/>





  <title>linux常用命令 | Tomasyao</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before">
          <i style="background:rgba(204,163,81,0.8);height:2px;"></i>
        </span>
        <span class="site-title">Tomasyao</span>
        <span class="logo-line-after">
          <i style="background:rgba(204,163,81,0.8);height:2px;"></i>
        </span>
      </a>
    </div>
      
        <p class="site-subtitle">与世界分享我刚编的故事</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://tomasyao.gitee.info/2017/07/11/linux常用命令/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="tomasyao">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://pic.tomasyao.info/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Tomasyao">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">linux常用命令</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-07-11T16:48:59+08:00">
                2017-07-11
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  554
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  2
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="网络"><a href="#网络" class="headerlink" title="网络"></a>网络</h2><blockquote>
<p>apt install net-tools       # ifconfig<br>apt install iputils-ping     # ping<br>netstat -ant | grep 4000     #查看端口占用</p>
</blockquote>
<a id="more"></a>
<h2 id="进程管理"><a href="#进程管理" class="headerlink" title="进程管理"></a>进程管理</h2><blockquote>
<p>ps aux | grep nginx<br>ps -le | more<br>pstree -pu<br>top<br>kill -l<br>kill -HUP (pid)  #平滑重启<br>kill -1 (pid)  #平滑重启<br>kill -KILL (pid)  #强制杀死进程<br>kill -9 (pid)  #强制杀死进程<br>killall -9 httpd<br>w #当前登录的用户<br>pkill -9 -t tty1 #按照终端号踢出用户</p>
</blockquote>
<h2 id="工作-后台-管理"><a href="#工作-后台-管理" class="headerlink" title="工作(后台)管理"></a>工作(后台)管理</h2><blockquote>
<p>jobs -l #显示工作的pid<br>(command) &amp; #放在后台执行<br>ctrl+z #放在后台暂停<br>find / -name tomasyao &amp;<br>/usr/local/mysql/bin/mysqld –user=mysql &amp; #d就是daemon守护进程<br>后台命令脱离登录终端执行：</p>
<ol>
<li>/etc/rc.local</li>
<li>系统定时任务</li>
<li>nohup</li>
</ol>
</blockquote>
<h2 id="系统资源查看"><a href="#系统资源查看" class="headerlink" title="系统资源查看"></a>系统资源查看</h2><blockquote>
<p>vmstat 1 3 #[刷新延迟，刷新次数]<br>dmesg #内核自启信息<br>dmesg | grep CPU<br>free #内存使用状态<br>cat /proc/cpuinfo<br>uptime<br>uname -a<br>file /bin/ls #判断当前系统的位数<br>lsb_release -a #发行版<br>lsof /sbin/init</p>
</blockquote>
<h2 id="系统定时任务"><a href="#系统定时任务" class="headerlink" title="系统定时任务"></a>系统定时任务</h2><blockquote>
<p>at now +2 minutes<br>atq<br>atrm<br>crontab -e(编辑)<br>***** 执行的任务</p>
<ol>
<li>* 一小时当中的第几分钟 0-59</li>
<li>* 一天当中的第几小时 0-23</li>
<li>* 一个月当中的第几天 1-31</li>
<li>* 一年当中的第几月 1-12</li>
<li>* 一周当中的星期几 0-7(0-7都代表星期日)<br>特殊符号<br><strong>*</strong> 任何时间(第一个*代表一小时每分钟执行一次)<br><strong>,</strong> 不连续时间 0 8,12,16 * * * 命令(每天8点0分，12点0分，16点0分执行)<br><strong>-</strong> 连续时间范围 0 5 * * 1-6 命令(周一到周六的凌晨5点0分执行)<br><strong>*/n</strong> 间隔执行 */10 * * * * 命令(每隔10分钟执行)<br>crontab -l<br>crontab -r<br>/etc/crontab</li>
</ol>
</blockquote>
<h2 id="目录文件权限"><a href="#目录文件权限" class="headerlink" title="目录文件权限"></a>目录文件权限</h2><blockquote>
<p>文件 最高权限 x<br>目录 最高权限 w<br>    0 5(rx) 7(rwx)<br>    4 1 6<br>useradd user1<br>passwd user1<br>chmod<br>chown #修改文件的所有者<br>chgrp #修改文件的所有组<br>groupadd user<br>gpasswd -a user1 user #将user1加到user组<br>chown user1:user dir<br>umask<br>文件默认不能建立为执行文件，必须手工赋予执行权限<br>所以文件默认权限最大为666<br>默认权限需要换算成字母再相减<br>建立文件之后的默认权限，为666减去umask<br>目录默认权限最大为777<br>永久修改<br>vi /etc/profile</p>
</blockquote>

      
    </div>
    
    
    
    
        <div>
        
    <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>


      </div>
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="http://pic.tomasyao.info/lALPACOG81QLSKnNBHDNAzw_828_1136.png_620x10000q90g.jpg" alt="tomasyao 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="http://pic.tomasyao.info/lADPACOG81QJkZHNBETNAtA_720_1092.jpg_620x10000q90g.jpg" alt="tomasyao 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/linux/" rel="tag"><i class="fa fa-tag"></i> linux</a>
          
            <a href="/tags/命令/" rel="tag"><i class="fa fa-tag"></i> 命令</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/07/09/fastdfs-nginx搭建简单图床/" rel="next" title="fastdfs+nginx搭建简单图床">
                <i class="fa fa-chevron-left"></i> fastdfs+nginx搭建简单图床
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/07/13/在Ubuntu上解压安装mysql/" rel="prev" title="在centos7.3 64bit系统上解压安装mysql">
                在centos7.3 64bit系统上解压安装mysql <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="http://pic.tomasyao.info/avatar.png"
                alt="tomasyao" />
            
              <p class="site-author-name" itemprop="name">tomasyao</p>
              <p class="site-description motion-element" itemprop="description">D9lab</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives">
              
                  <span class="site-state-item-count">26</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">1</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">39</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-inline">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.uisdc.com/" title="优设" target="_blank">优设</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.zhangxinxu.com/" title="张鑫旭" target="_blank">张鑫旭</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.alloyteam.com/nav/" title="Web前端导航" target="_blank">Web前端导航</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.36zhen.com/t?id=3448" title="前端书籍资料" target="_blank">前端书籍资料</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://ife.baidu.com/" title="百度前端技术学院" target="_blank">百度前端技术学院</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://wf.uisdc.com/cn/" title="google前端开发基础" target="_blank">google前端开发基础</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#网络"><span class="nav-number">1.</span> <span class="nav-text">网络</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#进程管理"><span class="nav-number">2.</span> <span class="nav-text">进程管理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#工作-后台-管理"><span class="nav-number">3.</span> <span class="nav-text">工作(后台)管理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#系统资源查看"><span class="nav-number">4.</span> <span class="nav-text">系统资源查看</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#系统定时任务"><span class="nav-number">5.</span> <span class="nav-text">系统定时任务</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#目录文件权限"><span class="nav-number">6.</span> <span class="nav-text">目录文件权限</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">tomasyao</span>

  
</div>


  <div class="powered-by">
  <i class="fa fa-user-md"></i><span id="busuanzi_container_site_uv">
    本站访客数:<span id="busuanzi_value_site_uv"></span>
  </span>
  </div>



  <span class="post-meta-divider">|</span>



  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>





  <span class="post-meta-divider">|</span>



  <div class="theme-info">
    <div class="powered-by"></div>
    <span class="post-count">博客全站共16.8k字</span>
  </div>


        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

  <!-- 页面点击小红心 -->
  <script type="text/javascript" src="/js/src/love.js"></script>
<script src="/live2dw/lib/L2Dwidget.min.js?0c58a1486de42ac6cc1c59c7d98ae887"></script><script>L2Dwidget.init({"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618,"jsonPath":"/live2dw/assets/tororo.model.json"},"display":{"superSample":2,"width":80,"height":100,"position":"right","hOffset":30,"vOffset":10},"mobile":{"show":true,"scale":0.5},"react":{"opacityDefault":1,"opacityOnHover":1},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
